with v8.Class_Value, v8.Class_Object, v8.Class_Function;
package v8.Class_Arguments is
   type Arguments (<>) is tagged limited private;
   type Pointer is access all Arguments;
   -- The argument information given to function call callbacks.  This
   -- class provides access to information about the context of the call,
   -- including the receiver, the number and values of arguments, and
   -- the holder of the function.

   function Length (this : Arguments) return int32_t;

   function Get (this : Arguments; i : int32_t) return v8.Class_Value.Pointer;

   function Callee (this : Arguments) return v8.Class_Function.Pointer;

   function This (this : Arguments) return v8.Class_Object.Pointer;

   function Holder (this : Arguments) return v8.Class_Object.Pointer;

   function Is_Construct_Call (this : Arguments) return Boolean;

   function Data (this : Arguments) return v8.Class_Value.Pointer;

   type Invocation_Callback is access function
     (args : Arguments
     ) return v8.Class_Value.Pointer;


private
   type Arguments is tagged limited null record;


   pragma Convention (CPP, Invocation_Callback);


   type Internal_Arguments is limited record
      implicit_args     : aliased uint32_t;
      values            : aliased uint32_t;
      length            : aliased int32_t;
      is_construct_call : aliased bool;
   end record;

   -- values => base stack pointer, values + 1 => this
   -- --------------------------------------------------
   -- &arguments(n - 1) => values - (n - 1)
   -- &arguments(n - 2)
   -- ..
   -- &arguments(0) => values
   -- &this => values + 1

   -- implicit_args => implicit_args ptr
   -- -----------------------------------------
   -- &holder => implicit_args - 2
   -- &callee => implicit_args - 1
   -- &data => implicit_args


   function Internal_Get_Length (This : Internal_Arguments) return int32_t;
   function Internal_Get_This (This : Internal_Arguments) return uint32_t;
   function Internal_Get_Callee (This : Internal_Arguments) return uint32_t;
   function Internal_Get_Holder (This : Internal_Arguments) return uint32_t;
   function Internal_Get_Argument (This : Internal_Arguments; i : uint32_t) return uint32_t;
   function Internal_Is_Construct_Call (This : Internal_Arguments) return Boolean;
   function Internal_Get_Data (This : Internal_Arguments) return uint32_t;

   for Length'Address use Internal_Get_Length'Address;
   for This'Address use Internal_Get_This'Address;
   for Callee'Address use Internal_Get_Callee'Address;
   for Holder'Address use Internal_Get_Holder'Address;
   for Get'Address use Internal_Get_Argument'Address;
   for Data'Address use Internal_Get_Data'Address;
   for Is_Construct_Call'Address use Internal_Is_Construct_Call'Address;

   pragma Import (Ada, Length);
   pragma Import (Ada, This);
   pragma Import (Ada, Callee);
   pragma Import (Ada, Holder);
   pragma Import (Ada, Data);
   pragma Import (Ada, Is_Construct_Call);
   pragma Import (Ada, Get);


end v8.Class_Arguments;
